package com.bailu.zsb_back.mapper;

import com.bailu.zsb_back.entity.Book;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author dell
 */
@Mapper
public interface BookMapper {
//    @Select({"<script>" ,
//            " <bind name=\"pattern\" value=\"'%' + _parameter.getName() + '%'\" />" ,
//            "  SELECT * FROM t_book" ,
//            "  <where>" ,
//            "    <if test=\"name != null and name! =''\">",
//            "        name like   #{pattern}" ,
//            "    </if>" ,
//            "  </where>" ,
//            "</script>"
//    })
//List<Book> findAll(String name);
@Select({"<script>" ,
        " <bind name=\"pattern\" value=\"'%' + _parameter + '%'\"/>" ,
        "  SELECT * FROM t_book" ,
        "  <where>" ,
        "    <if test=\"_parameter != null and _parameter != ''\">",
        "         name like #{pattern}" ,
        "    </if>" ,
        "  </where>" ,
        "</script>"
})
List<Book> findAll(String name);
}
